package com.iqiyi.pps.epg.api.utils;

import org.apache.commons.lang.StringUtils;

import java.util.Date;
import java.util.Map;

/**
 * Created by karkarrotxu on 2016/5/23.
 */
public class PlayStatusUtil {
    private PlayStatusUtil() {
    }

    public static void addParamsByPlayStatus(Map<String, String> params, String playStatus) {
        if (StringUtils.isNotEmpty(playStatus)) {
            int statusValue = Integer.valueOf(playStatus);
            String queryDate = DateTimeUtil.parseToLString(new Date());
            switch (statusValue) {
                case 0:
                    params.put("GTT_program.start_play_time", queryDate);
                    break;
                case 1:
                    params.put("LET_program.start_play_time", queryDate);
                    params.put("GET_program.stop_play_time", queryDate);
                    break;
                case 2:
                    params.put("LTT_program.stop_play_time", queryDate);
                    params.put("GET_TIMESTAMPADD(SECOND,channel.max_playback_period,program.start_play_time)", queryDate);
                    break;
                case 3:
                    params.put("LTT_TIMESTAMPADD(SECOND,channel.max_playback_period,program.start_play_time)", queryDate);
                    break;
                default:
                    break;
            }
        }
    }

    public static void addParamsByDirectorProgramStatus(Map<String, String> params, String programStatus) {
        if (programStatus != null) {
            int statusValue =Integer.valueOf(programStatus);
            long checkTime = new Date().getTime();
            String queryDate = DateTimeUtil.transLongFormat(checkTime);
            switch (statusValue) {
                case 0:
                    params.put("GTT_startPlayTime", queryDate);
                    break;
                case 1:
                    params.put("LET_startPlayTime", queryDate);
                    params.put("GET_stopPlayTime", queryDate);
                    break;
                case 2:
                    params.put("LTT_stopPlayTime", queryDate);
                    checkTime = checkTime - 172800000l;
                    params.put("GET_startPlayTime", DateTimeUtil.transLongFormat(checkTime));
                    break;
                case 3:
                    checkTime = checkTime - 172800000l;
                    params.put("LTT_startPlayTime", DateTimeUtil.transLongFormat(checkTime));
                    break;
                default:
                    break;
            }
        }
    }

}
